import { get } from 'lodash-es'
import router from '@/router'

export function getQueryParam(param: string | string[], defaultVal = '') {
  console.log(param, defaultVal)
  const query = router.currentRoute.value?.query ?? {}
  console.log(query)
  const val = get(query, param) ?? defaultVal
  console.log(val)
  return decodeURIComponent(val)
}

export function getToken() {
  const token = localStorage.getItem('token')
  return token
}

export function setToken(token: string) {
  localStorage.setItem('token', token)
}
